﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Data;
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using System.Configuration;

namespace ASBCC.Database.Service
{
    public class UserService
    {
        public static  bool IsSBGUser(int user_Id)
        {
            string sql = string.Format(@"SELECT * FROM (SELECT * FROM V_USER_INFO_EVM UNION SELECT * FROM V_USER_INFO_SVG) T WHERE USER_ID = {0}", user_Id);
            DataSet ds = SqlDataHelper.ExecuteDataset(
                DatabaseManager.ConnectionString,
                CommandType.Text,
                sql);
            if (ds == null || ds.Tables.Count == 0 || ds.Tables[0].Rows.Count == 0) return false;
            return true;         
       }

       public static string GetDepartment(string userid)
       { 
            string sql = string.Format(@"
                SELECT hp2.PARTY_CODE FROM USER_INFO LEFT JOIN HR_PARTY hp1 ON HR_PARTY_ID = hp1.PARTY_ID
                LEFT JOIN HR_PARTY hp2 ON HP1.PARTY_PARENT = hp2.PARTY_ID
                WHERE USER_ID = {0}
                ", userid);
           object objScalar = SqlDataHelper.ExecuteScalar(
               DatabaseManager.ConnectionString,
                CommandType.Text,
                sql);
           return Convert.ToString(objScalar);
       }
    }
}
